package com.dolittle.test;

import android.content.Context;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListAdapter;
import android.widget.ListView;

public class WordListView extends ListView {

	private Context mContext;
	private WordList mList;
	private DolittleTestActivity mActivity;

	public WordListView(Context context, WordList list,
			DolittleTestActivity activity) {
		super(context);
		mContext = context;
		mList = list;
		mActivity = activity;
		ListAdapter adapter = new ArrayAdapter<Word>(mContext,
				android.R.layout.simple_list_item_1, mList.getList());
		setAdapter(adapter);
		setOnItemClickListener(new OnItemClickListener() {
			public void onItemClick(AdapterView<?> parent, View view,
					int position, long id) {
				Word word = mList.getList().get(position);
				mActivity.goToEdit(word);
			}
		});
	}
}
